<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Git基本操作</title>
    <link rel="stylesheet" href="css/reveal.css">
    <link rel="stylesheet" href="css/theme/black.css">
    <link rel="stylesheet" href="lib/css/zenburn.css">
    <style>
        .left {
            text-align: left !important;
        }
    </style>
</head>
<body>
    <div class="reveal">
        <div class="slides">
            <section>
                <h2>Git基本操作</h2>
                <p>
                    <small>Created by @钢银UED-张喆懿</small>
                </p>
            </section>
            <section data-markdown>
                <script type="text/template">
                    * 基本命令

                    * 分支管理

                    * 冲突解决
                </script>
            </section>
            <section>
                <section>
                    <h3>基本命令</h3>
                </section>
                <section>
                    <p>配置用户 <em>config</em></p>
                    <pre class="fragment"><code>$ git config --global user.name "echozhangzy"</code></pre>
                    <pre class="fragment"><code>$ git config --global user.email "81675376@qq.com"</code></pre>
                </section>
                <section>
                    <p>创建本地版本库 <em>init</em></p>
                    <pre class="fragment"><code>$ mkdir gittest
$ cd gittest
$ git init</code></pre>
                </section>
                <section>
                    <p>添加远程仓库 <em>remote</em></p>
                    <pre class="fragment"><code>$ git remote add origin https://git.oschina.net/zhangzheyi/gitDemo.git</code></pre>
                    <pre class="fragment"><code>$ git remote set-url origin https://git.oschina.net/zhangzheyi/gitDemo.git</code></pre>
                </section>
                <section>
                    <p>克隆远程仓库 <em>clone</em></p>
                    <pre class="fragment"><code>$ git clone https://git.oschina.net/zhangzheyi/gitDemo.git</code></pre>
                </section>
                <section>
                    <p>查看状态 <em>status</em></p>
                    <pre class="fragment"><code>$ git status</code></pre>
                    <p class="fragment">忽略某些文件？</p>
                    <p class="fragment">.gitignore</p>
                    <pre class="fragment"><code>npm install -g gitignore &amp;&amp; gitignore c++</code></pre>
                </section>
                <section>
                    <p>添加文件至暂存区 <em>add</em></p>
                    <pre class="fragment"><code>$ git add &lt;file&gt;</code></pre>
                    <p class="fragment"  data-markdown>
                        <script type="text/template">
                            `git add .`

                            `git add -u`

                            `git add -A`
                        </script>
                    </p>
                </section>
                <section>
                    <p>提交修改 <em>commit</em></p>
                    <pre class="fragment"><code>$ git commit -m 'commit message'</code></pre>
                </section>
                <section>
                    <p>双剑合璧 <em>commit -am</em></p>
                    <pre class="fragment"><code>$ git commit -am 'commit message'</code></pre>
                </section>
                <section>
                    <p>撤销修改</p>
                    <pre class="fragment"><code>$ git checkout &lt;file&gt;</code></pre>
                    <pre class="fragment"><code>$ git reset HEAD &lt;file&gt;</code></pre>
                </section>
                <section>
                    <p>推送到远端 <em>push</em></p>
                    <pre class="fragment"><code>$ git push origin master</code></pre>

                </section>
                <section>
                    <p>获取远端代码 <em>push</em></p>
                    <pre class="fragment"><code>$ git pull origin master</code></pre>
                </section>
                <section>
                    <p>查看日志 <em>log</em></p>
                    <pre class="fragment"><code>$ git log</code></pre>
                    <pre class="fragment"><code>$ git show</code></pre>
                    <pre class="fragment"><code>$ git reflog</code></pre>
                </section>
                <section>
                    <p>查看不同 <em>diff</em></p>
                    <pre class="fragment"><code>$ git diff</code></pre>
                </section>
            </section>
            <section>
                <section>
                    <h3>分支管理</h3>
                </section>
                <section>
                    <p>查看分支列表 <em>branch</em></p>
                    <pre class="fragment"><code>$ git branch</code></pre>
                    <pre class="fragment"><code>$ git branch -r</code></pre>
                    <pre class="fragment"><code>$ git branch -a</code></pre>
                </section>
                <section>
                    <p>切换分支<em>checkout</em></p>
                    <pre class="fragment"><code>$ git checkout branchname</code></pre>
                    <p class="fragment">切不到？</p>
                    <pre class="fragment"><code>$ git fetch --all</code></pre>
                </section>
                <section>
                    <p>创建分支</p>
                    <pre class="fragment"><code>$ git branch newbranch master</code></pre>
                    <pre class="fragment"><code>$ git checkout -b newbranch master</code></pre>
                </section>
                <section>
                    <p>重命名分支 <em>branch -m</em></p>
                    <pre class="fragment"><code>$ git branch -m newbranch</code></pre>
                </section>
                <section>
                    <p>删除本地分支 <em>branch -d</em></p>
                    <pre class="fragment"><code>$ git branch -d branchname</code></pre>
                </section>
                <section>
                    <p>删除远程分支</p>
                    <pre class="fragment"><code>$ git branch -r -d origin/branchname</code></pre>
                    <pre class="fragment"><code>$ git push orgin :branchname</code></pre>
                </section>
                <section>
                    <p>合并分支 <em>merge</em></p>
                    <pre class="fragment"><code>$ git merge dev</code></pre>
                </section>
            </section>
            <section>
                <section>
                    <h3>解决冲突</h3>
                </section>
                <section>
                    <pre><code><<<<<<< HEAD
hello world
=======
你好，世界
>>>>>>> dev</code></pre>
                    <p class="fragment">无他，手动解决之</p>
                </section>
                <section>
                    <p>二选一</p>
                    <pre class="fragment"><code>$ git checkout --theirs &lt;file&gt;</code></pre>
                    <pre class="fragment"><code>$ git checkout --ours .</code></pre>
                </section>
            </section>
            <section>
                <section>
                    <h2>谢谢</h2>
                </section>
               
            </section>
        </div>
    </div>
    <script src="lib/js/head.min.js"></script>
    <script src="js/reveal.js"></script>
    <script>
        // More info https://github.com/hakimel/reveal.js#configuration
        Reveal.initialize({
            controls: true,
            progress: true,
            history: true,
            center: true,
            slideNumber: 'c/t',
            transition: 'slide', // none/fade/slide/convex/concave/zoom
            // More info https://github.com/hakimel/reveal.js#dependencies
            dependencies: [
                { src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
                { src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
                { src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
                { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
                { src: 'plugin/zoom-js/zoom.js', async: true },
                { src: 'plugin/notes/notes.js', async: true }
            ]
        });
    </script>
</body>
</html>
